package com.atguigu.spzx;

import com.atguigu.spzx.common.constant.RedisConst;
import com.atguigu.spzx.common.log.annotation.EnableLogAspect;
import com.atguigu.spzx.manager.properties.MinioProperties;
import com.atguigu.spzx.manager.properties.UserAuthProperties;
import org.assertj.core.api.LongAssert;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@EnableConfigurationProperties(value = {UserAuthProperties.class, MinioProperties.class}) //方式二，加载属性类，创建这个类对象，进行属性批量注入
//@EnableTransactionManagement //默认开启
@EnableScheduling //开启定时任务功能
//@ComponentScan(basePackages = "com.atguigu")
//@Import(value = {LongAssert.class}) //导入指定类。
@EnableLogAspect //开启日志模块功能
public class ManagerApplication implements CommandLineRunner {

    @Autowired
    RedissonClient redissonClient;

    public static void main(String[] args) {
        SpringApplication.run(ManagerApplication.class);
    }

    //后台管理系统启动时，会初始化布隆过滤器（一组二进制位数组 + hash()函数）
    @Override
    public void run(String... args) throws Exception {
        RBloomFilter<Object> bloomFilter = redissonClient.getBloomFilter(RedisConst.PRODUCT_BLOOM_FILTER);
        bloomFilter.tryInit(1000,0.1); //保存数据的数量，误判率
    }
}
